package com.example.mobile2030606148tdh0323homework;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EditText edtTxtAcount=findViewById(R.id.edtText_accout);
        EditText edtTxtPSW=findViewById(R.id.edtText_newpsw);
        EditText edtTxtoldPsw=findViewById(R.id.edtText_oldpsw);
        EditText edtTxtPSW2=findViewById(R.id.edtText_psw2);
        Button btn_01 = findViewById(R.id.button);
        btn_01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String str =edtTxtAcount.getText().toString();
                String str1 =edtTxtoldPsw.getText().toString();
                String str2 =edtTxtPSW.getText().toString();
                String str3 = edtTxtPSW2.getText().toString();

                if (str1.equals("abc123")) {
                    if (str2.equals(str3)) {
                        Toast.makeText(MainActivity.this, "密码修改成功", Toast.LENGTH_SHORT).show();

                    } else {
                        edtTxtPSW2.setText("两次密码不一致，请重新输入");

                    }
                }else{
                    edtTxtoldPsw.setText("原密码错误");
                }
            }
        });


    }
}